﻿using System;
using System.IO;
using System.Xml.Serialization;
using TShooter.TfsWord.Xml;

namespace TShooter.TfsWord.TeamFoundation
{
    [XmlRoot("WorkItemInfo", Namespace = Consts.XmlNamespace)]
    public class WorkItemInfo
    {
        private static XmlSerializer _Serializer;

        public string WorkItemType { get; set; }
        public int ID { get; set; }
        public int Revision { get; set; }

        private static XmlSerializer Serializer
        {
            get
            {
                if (_Serializer == null)
                {
                    _Serializer = new XmlSerializer(typeof (WorkItemInfo));
                }
                return _Serializer;
            }
        }

        public override string ToString()
        {
            var sw = new StringWriter();
            Serializer.Serialize(sw, this);

            return sw.ToString();
        }
    }
}
